package student;
import base.Person;
import course.Course;

public class Student extends Person {
    private Course selectedCourse;

    public Student(String id, String name, String gender) {
        super(id, name, gender);
    }

    public void selectCourse(Course course) {
        this.selectedCourse = course;
        System.out.println(name + " 成功选修《" + course.getName() + "》");
    }

    // 带Course参数的退课方法
    public void dropCourse(Course course) {
        if (selectedCourse != null && selectedCourse.equals(course)) {
            System.out.println(name + " 退选《" + course.getName() + "》成功");
            selectedCourse = null;
        } else {
            System.out.println(name + " 无该课程选课记录");
        }
    }

    @Override
    public void showBasicInfo() {
        super.showBasicInfo();
        if (selectedCourse != null) {
            System.out.println("所选课程：《" + selectedCourse.getName() + "》，上课地点：" + selectedCourse.getLocation());
        }
    }
}